<?PHP

/*
 * 用户权限
 * 杨继康
 * 2012/07/22
 */

class Role_Model extends CI_Model {

    //重载CI_Model
    public function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->model('Base_Model');
    }

    /*
     * Insert_Product
     * 写入数据库
     */

    function Insert_Role($id, $data = FALSE) {
        $this->Delete($id);
        //删除后继续重新添加
        $result = $this->db->insert('db_role', $data);
        return $result;
    }

    /*
     * GetEntity
     * 获取单挑数据
     * 参数：pt_id
     */

    function GetEntity($str = FALSE) {
        if ($str != "") {
            $query = $this->db->get_where('db_role', array('u_id' => $str));
            //返回结果
            $Array = $query->result_array();
            if ($Array == NULL) {
                $Array = array(array("u_id" => '', "ro_content" => ''));
            }
        } else {
            $Array = array(array("u_id" => '', "ro_content" => ''));
        }
        return $Array;
    }

    /*
     * Delete
     * 删除数据
     */

    function Delete($id = FALSE) {
        $query = $this->db->get_where('db_role', array('u_id' => $id));
        $str = $query->result_array();
        //如果查询存在
        if ($str != "") {
            $this->db->delete('db_role', array('u_id' => $id));
        }
    }

}

?>